home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / indexing / IXFileFinder.h < prev    next >
Text File  |  1994-04-13  |  8KB  |  221 lines

  1. /*
  2. IXFileFinder.h
  3. Copyright 1991, NeXT Computer, Inc.
  4. */
  5.  
  6. #import <objc/hashtable.h>
  7. #import    <machkit/reference.h>
  8.  
  9. #import    "IXPostingList.h"
  10.  
  11. @class IXBTree, IXFileFinder, IXFileRecord;
  12.  
  13. typedef struct             {
  14.     unsigned            recordNumber;
  15.     unsigned            dateModified;
  16. } IXFileRegistration;
  17.  
  18. @protocol IXFileFinderQueryAndUpdate
  19.  
  20. - (const char *)rootPath; // returns the root path
  21.  
  22. // Returns the file finder's record manager.  The file finder forwards all 
  23. // unrecognized messages to its record manager.
  24. - recordManager;
  25.  
  26. - (char *)attributeNames; // returns the names of indexed attributes
  27.  
  28. - clean; // removes stale information from the index
  29. - reset; // removes everything from the index
  30.  
  31. // updates the index in the caller's thread, starting at the supplied path.
  32. - updateIndexAtPath:(const char *)path forSender:aSender;
  33.  
  34. - (BOOL)isUpdating; // true when asynchronous updating is in progress
  35. - resumeUpdating; // resumes asynchronous updating
  36. - suspendUpdating; // suspends asynchronous updating
  37.  
  38. - stopQueryForSender:aSender; // stops a recursive descent in progress
  39. - (IXPostingList *)performQuery:(const char *)query 
  40.     atPath:(const char *)path forSender:aSender;
  41.  
  42. // This method returns the registry used by the file finder.  The keys are 
  43. // relative file names, and the values are instances of the IXFileRegistration 
  44. // structure defined above.  The registry should be considered read only.
  45. - (IXBTree *)registry;
  46.  
  47. @end
  48.  
  49. @interface Object(IXFileFinderSender)
  50.  
  51. // Called with the list of index results before recursive descent is started.
  52. - fileFinder:(IXFileFinder *)aFinder 
  53.     didFindFiles:(IXPostingList *)aList;
  54.  
  55. // Called during recursive descent for each file visited before the file date 
  56. // is compared with the registry for currency.  If the return value is NO, the 
  57. // file will be skipped.
  58. - (BOOL)fileFinder:(IXFileFinder *)aFinder 
  59.     willTryPath:(const char *)filename;
  60.  
  61. // Called during recursive descent for each modified file before parsing the 
  62. // file contents or testing for conformance to the query.  This method returns 
  63. // its second argument, or a new file record that replaces its second argument.
  64. - fileFinder:(IXFileFinder *)aFinder 
  65.     willAddFile:(IXFileRecord *)anObject;
  66.  
  67. // Called during recursive descent for each modified file after parsing and 
  68. // testing, but before adding the file to the index.  The file record contains 
  69. // a full complement of attribute bindings at this point.  This method returns 
  70. // its second argument, or a new file record that replaces its second argument.
  71. - fileFinder:(IXFileFinder *)aFinder 
  72.     didAddFile:(IXFileRecord *)anObject;
  73.  
  74. // Called during recursive descent for each file that satisfies the query.
  75. - fileFinder:(IXFileFinder *)aFinder 
  76.     didFindFile:(IXFileRecord *)anObject;
  77.  
  78. @end
  79.  
  80. @protocol IXFinderControl
  81.  
  82. // Returns self, or nil to deny enumeration of the named directory.  
  83. - fileFinder:(IXFileFinder *)aFinder willEnumerate:(char *)filename;
  84.  
  85. // Called to allow subsidiary file finders to be recursively queried.
  86. - (IXPostingList *)fileFinder:(IXFileFinder *)aFinder 
  87.     didPerform:(char *)query atPath:(char *)path forSender:aSender;
  88.  
  89. @end
  90.  
  91. @protocol IXFileFinderConfiguration
  92.  
  93. // These methods manage the list of parsers used by a file finder.  The list 
  94. // is searched for a parser that understands the type of the file being parsed.
  95.  
  96. - getAttributeParsers:(List *)aList;
  97. - setAttributeParsers:(List *)aList;
  98.  
  99. // The following methods read and write ignored types using strings.
  100.  
  101. - (char *)ignoredTypes; // returns the list of ignored types
  102. - setIgnoredTypes:(const char *)types; // sets the list of ignored types
  103.  
  104. // The following methods read and write ignored types using streams.
  105.  
  106. - readIgnoredTypes:(NXStream *)aStream;
  107. - writeIgnoredTypes:(NXStream *)aStream;
  108.  
  109. // The following methods read and write ignored types using files.
  110.  
  111. - readIgnoredTypesFromFile:(const char *)filename;
  112. - writeIgnoredTypesToFile:(const char *)filename;
  113.  
  114. // The following methods read and write ignored names using strings.
  115.  
  116. - (char *)ignoredNames; // returns the list of ignored names
  117. - setIgnoredNames:(const char *)names; // sets the list of ignored names
  118.  
  119. // The following methods read and write ignored names using streams.
  120.  
  121. - readIgnoredNames:(NXStream *)aStream;
  122. - writeIgnoredNames:(NXStream *)aStream;
  123.  
  124. // The following methods read and write ignored names using files.
  125.  
  126. - readIgnoredNamesFromFile:(const char *)filename;
  127. - writeIgnoredNamesToFile:(const char *)filename;
  128.  
  129. // N.B.: the hidden file policy is not preserved across archiving 
  130. // or across closing the store.  it defaults to NO at initialization.
  131.  
  132. - (BOOL)considersHiddenFiles; // returns hidden file policy
  133. - setConsidersHiddenFiles:(BOOL)flag; // sets hidden file policy
  134.  
  135. - (BOOL)crossesDeviceChanges; // returns device crossing policy
  136. - setCrossesDeviceChanges:(BOOL)flag; // sets device crossing policy
  137.  
  138. - (BOOL)followsSymbolicLinks; // returns symbolic link policy
  139. - setFollowsSymbolicLinks:(BOOL)flag; // sets symbolic link policy
  140.  
  141. - (BOOL)generatesDescriptions; // returns description generation policy
  142. - setGeneratesDescriptions:(BOOL)flag; // sets description generation policy
  143.  
  144. - (BOOL)updatesAutomatically; // returns automatic update policy
  145. - setUpdatesAutomatically:(BOOL)flag; // sets automatic update policy
  146.  
  147. - (BOOL)scansForModifiedFiles; // returns file scanning policy
  148. - setScansForModifiedFiles:(BOOL)flag; // sets file scanning policy
  149.  
  150. - (BOOL)removesAutomatically; // sets the automatic removal policy
  151. - setRemovesAutomatically:(BOOL)aBoolean; // returns automatic removal policy
  152.  
  153. - (unsigned)commitDelay; // returns the commit delay in seconds
  154. - setCommitDelay:(unsigned)seconds; // sets the commit delay for updating
  155.  
  156. - (id <IXFinderControl>)finderControl; // sets the controller for recursion
  157. - setFinderControl:(id <IXFinderControl>)anObject; // returns the controller
  158.  
  159. @end
  160.  
  161. // an instance of this class manages the inversion of a single rootPath tree in the file system.  multiple queries may be run concurrently with updating.
  162.  
  163. @interface IXFileFinder: Object <NXReference, IXNameAndFileAccess, IXFileFinderQueryAndUpdate, IXFileFinderConfiguration, IXAttributeBinding>
  164. {
  165.     struct FinderRecord    *_finderRecord;
  166.     unsigned        references; // the reference count
  167.     List        *attributeParsers; // the list of attribute parsers
  168.     id            recordManager; // the supporting record manager
  169.     NXHashTable        *ignoredNames; // table of ignored names
  170.     NXHashTable        *ignoredTypes; // table of ignored types
  171.     char        *rootPath; // the root path
  172.     unsigned        commitDelay; // transaction commit delay in seconds
  173.     struct        {
  174.     unsigned    crossesDeviceChanges:1; // crosses device changes
  175.     unsigned    followsSymbolicLinks:1; // follows symbolic links
  176.     unsigned    generatesDescriptions:1; // generates descriptions
  177.     unsigned    updatesAutomatically:1; // queries request updates
  178.     unsigned    scansForModifiedFiles:1; // scans for modified files
  179.     unsigned    removesAutomatically:1; // scans for removed files
  180.     unsigned    considersHiddenFiles:1; // considers hidden files
  181.     }             booleanOptions;
  182. }
  183.  
  184. // Returns the store, e.g., [[client store] startTransaction].
  185. - (IXStore *)store;
  186.  
  187.  
  188. // The following methods are analagous to the initialization methods defined  
  189. // by the IXBlockAndStoreAccess and IXNameAndFileAccess protocols.  The path 
  190. // supplied to the methods is the root of the file system subtree managed by 
  191. // the file finder.  A file finder may be rerooted simply by opening it with a 
  192. // new root path.  If the protocol methods are used, then the current working 
  193. // directory is used as the default root path parameter.
  194.  
  195. - initInStore:(IXStore *)aStore 
  196.     atPath:(const char *)path;
  197. - initFromBlock:(unsigned)block inStore:(IXStore *)aStore 
  198.     atPath:(const char *)path;
  199.  
  200. - initWithName:(const char *)name inFile:(const char *)filename 
  201.     atPath:(const char *)path;
  202. - initFromName:(const char *)aName inFile:(const char *)filename 
  203.     forWriting:(BOOL)flag atPath:(const char *)path;
  204.  
  205. @end
  206.  
  207. #ifdef KANJI
  208.  
  209. #define IX_NOTDEF_ENCODING    0
  210. #define IX_NEXTSTEP_ENCODING    1
  211. #define IX_NJE_ENCODING    2
  212.  
  213. @interface IXFileFinder(QueryEncoding)
  214.  
  215. - (unsigned)queryEncoding;
  216. - setQueryEncoding:(unsigned)encoding;
  217.  
  218. @end
  219.  
  220. #endif KANJI
  221.